/*
 * 10.3.cpp 2533_poj
 *
 *  Created on: 2012-5-16
 *      Author: jawinton
 */


#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 1001

int arr[MAX];
int maxLen[MAX];

int subLen(int i) {
	if (i==0) maxLen[i]=1;
	if (maxLen[i] != -1) return maxLen[i];
	//int k = 0;
	int max = 0;
	for (int j=0; j<i; j++) {
		if (arr[i] > arr[j]) {
			int tmp = subLen(j);
			//if (tmp > maxLen[k] || (tmp == maxLen[k] && arr[j] < arr[k])) {
			//	k = j;
			//}
			if (max < tmp)
				max = tmp;
		}
	}
	maxLen[i] = max + 1;
	return maxLen[i];
}

int main (void) {
	int n;
	scanf("%d", &n);
	for (int i=0; i<n; i++) {
		scanf("%d", &arr[i]);
		maxLen[i] = -1;
	}
	for (int i=0; i<n; i++)
		subLen(i);
	int nMax = -1;
	for (int i=0; i<n; i++)
		if (nMax < maxLen[i])
			nMax = maxLen[i];
	printf("%d\n", nMax);
	return 0;
}
